package tools.chapter24;

import java.util.concurrent.CompletableFuture;

/**
 * @author Kevin
 * @date 2020/4/13 22:36
 */
public class CompletionStageDemo {
    public static void demo1() {
        //虽然是异步，但结果存在依赖.通过LockSupport::park使得任务串行
        CompletableFuture<String> f0 =
                CompletableFuture.supplyAsync(
                        ()->"hello world!")
                .thenApply(s -> s + "QQ")
                .thenApply(String::toUpperCase);
        //输出结果
        System.out.println(f0.join());
    }

    public static void main(String[] args) {
        demo1();
    }
}
